﻿using System;
using System.Linq;
using System.Web.Mvc;

namespace MusicStore.WebMVC.Controllers
{
    public class StoreController : BaseController
    {
        //
        // GET: /Store/

        public ViewResult Index()
        {
            var lsGenre = db.Genres.ToList();

            return View(lsGenre);
        }

        ///
        ///  Get: /Store/Browse?Genre=Rock
        
        public ViewResult Browse(string genre)
        {
            var genreModel = db.Genres.Include("Albums").Single(g => g.Name == genre);

            return View(genreModel);
        }

        /// 
        ///  Get: /Store/Details/1
        
        public ViewResult Details(int id)
        {
            var album = db.Albums.Find(id);

            return View(album);
        }

        // get: /store/genremenu

        [ChildActionOnly]
        public ActionResult GenreMenu()
        {
            var genres = db.Genres.ToList();
            
            return PartialView(genres);
        }
    }
}
